/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file    tm1650.h
  * @brief   TM1650 4-digit 7-segment display driver header file
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2025 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TM1650_H__
#define __TM1650_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* USER CODE BEGIN Private defines */
// TM1650 I2C Address
#define TM1650_I2C_ADDR    0x48

// TM1650 Commands
#define TM1650_CMD_DISPLAY_ON    0x01
#define TM1650_CMD_DISPLAY_OFF   0x00

// TM1650 Display positions
#define TM1650_POS1    0x68    // First digit
#define TM1650_POS2    0x6A    // Second digit  
#define TM1650_POS3    0x6C    // Third digit
#define TM1650_POS4    0x6E    // Fourth digit

// 7-segment display patterns (common cathode)
#define TM1650_DIGIT_0    0x3F
#define TM1650_DIGIT_1    0x06
#define TM1650_DIGIT_2    0x5B
#define TM1650_DIGIT_3    0x4F
#define TM1650_DIGIT_4    0x66
#define TM1650_DIGIT_5    0x6D
#define TM1650_DIGIT_6    0x7D
#define TM1650_DIGIT_7    0x07
#define TM1650_DIGIT_8    0x7F
#define TM1650_DIGIT_9    0x6F
#define TM1650_DIGIT_A    0x77
#define TM1650_DIGIT_B    0x7C
#define TM1650_DIGIT_C    0x39
#define TM1650_DIGIT_D    0x5E
#define TM1650_DIGIT_E    0x79
#define TM1650_DIGIT_F    0x71
#define TM1650_DIGIT_DASH 0x40
#define TM1650_DIGIT_BLANK 0x00

/* USER CODE END Private defines */

/* USER CODE BEGIN Prototypes */
void TM1650_Init(void);
void TM1650_DisplayOn(void);
void TM1650_DisplayOff(void);
void TM1650_SetBrightness(uint8_t brightness);
void TM1650_WriteDigit(uint8_t position, uint8_t digit);
void TM1650_WriteNumber(uint16_t number);
void TM1650_WriteString(char* str);
void TM1650_Clear(void);

/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif

#endif /*__ TM1650_H__ */
